<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\store\model\ding\foods;

use app\common\model\ding\FoodCategory as CategoryModel;
use app\common\service\store\User as UserService;
/**
 * 文章分类模型
 * Class Category
 * @package app\store\model\article
 */
class Category extends CategoryModel {


	/**
	 * 添加新记录
	 * @param $data
	 * @return false|int
	 */
	public function add(array $data) {
		// 保存记录
		$data['store_id'] = self::$storeId;
		return $this->save($data);
	}

	/**
	 * 编辑记录
	 * @param $data
	 * @return bool|int
	 */
	public function edit(array $data) {
		// 保存记录
		return $this->save($data);
	}
  /**
     * 获取列表
     * @param array $where
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getList(array $where = [])
    {

        $shop_id = UserService::getLoginInfo()['user']['shop_id'];

    	$where[]=['shop_id','=',$shop_id];
        return $this->where($where)
            ->order(['sort', $this->getPk()])
            ->select();
    }
	/**
	 * 删除商品分类
	 * @param int $categoryId
	 * @return bool
	 * @throws \Exception
	 */
	public function remove(int $categoryId) {
	
		// 删除记录
		return $this->delete();
	}

}
